import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class StreamTest {
    @Test
    public void test1() throws Exception {
        List<Integer> list = new ArrayList<>(List.of(100,200,300));
        list.stream().filter(i -> i >= 200).forEach(System.out::println);
        System.out.println("----------------------");
        list.stream().filter(i -> i >= 200).forEach(System.out::println);
        System.out.println("----------------------");
        list.stream().limit(2).forEach(System.out::println);
        System.out.println("----------------------");
        list.stream().skip(2).forEach(System.out::println);
    }
    
    @Test
    public void test2() throws Exception {
        List<Integer> list = new ArrayList<>(List.of(100,100,200,300));
        list.stream().distinct().forEach(System.out::println);
    }

    @Test
    public void test3() throws Exception {
        List<String> list = new ArrayList<>(List.of("aA", "Bb", "cc", "DD"));
        list.stream().map(String::toUpperCase).forEach(System.out::println);
        list.stream().map(String::toLowerCase).forEach(System.out::println);
    }
    
    @Test
    public void test4() throws Exception {
        List<String> list = new ArrayList<>(List.of(" aA", "Bb ", " cc", "DD  "));
        list.stream().map(String::trim).map(String::toUpperCase).forEach(System.out::println);
    }
}
